/*******************************************************************************
 *                                    ZLG
 *                         ----------------------------
 *                         innovating embedded platform
 *
 * Copyright (c) 2001-present Guangzhou ZHIYUAN Electronics Co., Ltd.
 * All rights reserved.
 *
 * Contact information:
 * web site:    https://www.zlg.cn
 *******************************************************************************/
/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "driver/esc/hpm6e00_esc.h"

/*******************************************************************************
 * Code
 ******************************************************************************/
/**
 * \brief ESC 时钟使能设置
 *
 * @param is_enable 是否使能
 */
void esc_core_clk_enable(bool_t is_enable){
    if (is_enable) {
        HPM_ESC->GPR_CFG0 |= ESC_GPR_CFG0_CLK100_EN_MASK;
    } else {
        HPM_ESC->GPR_CFG0 &= ~ESC_GPR_CFG0_CLK100_EN_MASK;
    }
}

/**
 * \brief ESC PHY 时钟使能设置
 *
 * @param is_enable 是否使能
 */
void esc_phy_clk_enable(bool_t is_enable){
    if (is_enable) {
        HPM_ESC->PHY_CFG1 |= ESC_PHY_CFG1_REFCK_25M_OE_MASK;
    } else {
        HPM_ESC->PHY_CFG1 &= ~ESC_PHY_CFG1_REFCK_25M_OE_MASK;
    }
}

